var host = 'http://localhost:3333/api/'
var model = 'online'   // dev  online
// var model = 'dev'   // dev  online

var m = {}
m.ajax = function (op) {
  if(model === 'dev'){
    var mockData = window[op.url.substring(1)]
    op.success(mockData || {})
    return false;
  }
  op.data = op.data ||{}
  $.ajax({
    type: op.type||'get',
    url: host + op.url || '',
    data: op.data,
    dataType:'text',  // 为了修复请求成功但是不走 success 方法 bug
    success: function (data) {
      if(typeof(data) === 'string'){
        op.success(JSON.parse(data))
      }else{
        op.success(data)
      }

    },
    error: op.error
  });
};